﻿using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using DBSourceToolsLib;
using DBConnectionLib;
//using NUnit.Extensions;


//namespace TestDBSourceToolsLibNUnit
//{
//    [TestFixture]
//    public class TestForm_NewDatabaseForm
//    {
//        [Test]
//        public void TestCancelButton()
//        {
//            using (DBSourceToolsLib.DatabaseProjectUI.NewDatabaseForm oNewDbForm
//                = new DBSourceToolsLib.DatabaseProjectUI.NewDatabaseForm(false, true))
//            {
//                oNewDbForm.Show();

//                //NUnit.Extensions.Forms.TextBoxTester oTB = new NUnit.Extensions.Forms.TextBoxTester("");
//                NUnit.Extensions.Forms.ButtonTester oCancel = new NUnit.Extensions.Forms.ButtonTester("btnCancel");

//                oCancel.Click();
//            }

//        }
//        [Test]
//        public void TestEnabledButtons()
//        {
//            using (DBSourceToolsLib.DatabaseProjectUI.NewDatabaseForm oNewDbForm
//                = new DBSourceToolsLib.DatabaseProjectUI.NewDatabaseForm(true, true))
//            {
//                oNewDbForm.Show();

//                NUnit.Extensions.Forms.ButtonTester btnOK = new NUnit.Extensions.Forms.ButtonTester("btnOk");
//                Assert.IsTrue(btnOK.Properties.Enabled == false, "btnOK should not be enabled");

//                // on initial load, all controls except for nickname should be dis-abled

//                NUnit.Extensions.Forms.TextBoxTester m_textBoxNickName = new NUnit.Extensions.Forms.TextBoxTester("m_textBoxNickName");
//                Assert.IsTrue(m_textBoxNickName.Properties.Enabled, " m_textBoxNickName should be enabled");

//                NUnit.Extensions.Forms.TextBoxTester m_textBoxDatabaseName = new NUnit.Extensions.Forms.TextBoxTester("m_textBoxDatabaseName");
//                Assert.IsTrue(m_textBoxDatabaseName.Properties.Enabled == false, " m_textBoxDatabaseName should be dis-abled");

//                NUnit.Extensions.Forms.ComboBoxTester m_comboBoxAuthentication = new NUnit.Extensions.Forms.ComboBoxTester("m_comboBoxAuthentication");
//                Assert.IsTrue(m_comboBoxAuthentication.Properties.Enabled == false, " m_comboBoxAuthentication should be dis-abled");

//                NUnit.Extensions.Forms.TextBoxTester m_textBoxServerName = new NUnit.Extensions.Forms.TextBoxTester("m_textBoxServerName");
//                Assert.IsTrue(m_textBoxServerName.Properties.Enabled == false, " m_textBoxServerName should be dis-abled");

//                NUnit.Extensions.Forms.ButtonTester btnTestConnection = new NUnit.Extensions.Forms.ButtonTester("btnTestConnection");
//                Assert.IsTrue(btnTestConnection.Properties.Enabled == false, " btnTestConnection should be dis-abled");
//            }
//        }
//        [Test]
//        public void TestEnableControlsAfterEnteringText_MustTestDb()
//        {
//            using (DBSourceToolsLib.DatabaseProjectUI.NewDatabaseForm oNewDbForm
//                = new DBSourceToolsLib.DatabaseProjectUI.NewDatabaseForm(true, true))
//            {
//                oNewDbForm.Show();

//                NUnit.Extensions.Forms.TextBoxTester m_textBoxNickName = new NUnit.Extensions.Forms.TextBoxTester("m_textBoxNickName");
//                NUnit.Extensions.Forms.TextBoxTester m_textBoxDatabaseName = new NUnit.Extensions.Forms.TextBoxTester("m_textBoxDatabaseName");
//                NUnit.Extensions.Forms.TextBoxTester m_textBoxServerName = new NUnit.Extensions.Forms.TextBoxTester("m_textBoxServerName");
//                NUnit.Extensions.Forms.ComboBoxTester m_comboBoxAuthentication = new NUnit.Extensions.Forms.ComboBoxTester("m_comboBoxAuthentication");
//                NUnit.Extensions.Forms.ButtonTester btnTestConnection = new NUnit.Extensions.Forms.ButtonTester("btnTestConnection");
//                NUnit.Extensions.Forms.TextBoxTester m_textBoxUserName = new NUnit.Extensions.Forms.TextBoxTester("m_textBoxUserName");
//                NUnit.Extensions.Forms.TextBoxTester m_textBoxPassword = new NUnit.Extensions.Forms.TextBoxTester("m_textBoxPassword");
//                NUnit.Extensions.Forms.ButtonTester btnOK = new NUnit.Extensions.Forms.ButtonTester("btnOk");

//                // once nick-name has been entered, then servername should be enabled.
//                m_textBoxNickName.Properties.Text = "testDatabase";
//                Assert.IsTrue(m_textBoxServerName.Properties.Enabled, " m_textBoxServerName should be enabled");

//                m_textBoxServerName.Properties.Text = ".";
//                Assert.IsTrue(m_textBoxDatabaseName.Properties.Enabled, " m_textBoxDatabaseName should be enabled");
//                Assert.IsTrue(m_comboBoxAuthentication.Properties.Enabled, " m_comboBoxAuthentication should be enabled");
                
//                // set them to null
//                m_textBoxServerName.Properties.Text = "";
//                Assert.IsTrue(m_textBoxDatabaseName.Properties.Enabled == false, " m_textBoxDatabaseName should not be enabled");
//                Assert.IsTrue(m_comboBoxAuthentication.Properties.Enabled == false, " m_comboBoxAuthentication should not be enabled");

//                m_textBoxNickName.Properties.Text = "";
//                Assert.IsTrue(m_textBoxServerName.Properties.Enabled == false, " m_textBoxServerName should not be enabled");

//                m_comboBoxAuthentication.Select(0);
//                Assert.IsTrue(m_textBoxUserName.Properties.Enabled == false, " m_textBoxUserName should not be enabled");
//                Assert.IsTrue(m_textBoxPassword.Properties.Enabled == false, " m_textBoxPassword should not be enabled");

//                m_comboBoxAuthentication.Select(1);
//                Assert.IsTrue(m_textBoxUserName.Properties.Enabled, " m_textBoxUserName should be enabled");
//                Assert.IsTrue(m_textBoxPassword.Properties.Enabled, " m_textBoxPassword should be enabled");

//                m_textBoxNickName.Properties.Text = "testDatabase";
//                m_textBoxServerName.Properties.Text = ".";
//                m_textBoxDatabaseName.Properties.Text = "DBSourceToolsTestDB";
//                Assert.IsTrue(btnOK.Properties.Enabled == false, " btnOK should not be enabled");
//                Assert.IsTrue(btnTestConnection.Properties.Enabled == true, " btnTestConnection should be enabled");

//                btnTestConnection.Click();
//                Assert.IsTrue(btnOK.Properties.Enabled == true, " btnOK should be enabled");

//                //Assert.IsTrue(btnTestConnection.Properties.Enabled == false, " btnTestConnection should be dis-abled");
//            }

//        }

//        [Test]
//        public void TestEnableControlsAfterEnteringText_MustNotTestDb()
//        {
//            using (DBSourceToolsLib.DatabaseProjectUI.NewDatabaseForm oNewDbForm
//                = new DBSourceToolsLib.DatabaseProjectUI.NewDatabaseForm(false, true))
//            {
//                oNewDbForm.Show();

//                NUnit.Extensions.Forms.TextBoxTester m_textBoxNickName = new NUnit.Extensions.Forms.TextBoxTester("m_textBoxNickName");
//                NUnit.Extensions.Forms.TextBoxTester m_textBoxDatabaseName = new NUnit.Extensions.Forms.TextBoxTester("m_textBoxDatabaseName");
//                NUnit.Extensions.Forms.TextBoxTester m_textBoxServerName = new NUnit.Extensions.Forms.TextBoxTester("m_textBoxServerName");
//                NUnit.Extensions.Forms.ComboBoxTester m_comboBoxAuthentication = new NUnit.Extensions.Forms.ComboBoxTester("m_comboBoxAuthentication");
//                NUnit.Extensions.Forms.ButtonTester btnTestConnection = new NUnit.Extensions.Forms.ButtonTester("btnTestConnection");
//                NUnit.Extensions.Forms.TextBoxTester m_textBoxUserName = new NUnit.Extensions.Forms.TextBoxTester("m_textBoxUserName");
//                NUnit.Extensions.Forms.TextBoxTester m_textBoxPassword = new NUnit.Extensions.Forms.TextBoxTester("m_textBoxPassword");
//                NUnit.Extensions.Forms.ButtonTester btnOK = new NUnit.Extensions.Forms.ButtonTester("btnOk");

//                // once nick-name has been entered, then servername should be enabled.
//                m_textBoxNickName.Properties.Text = "testDatabase";
//                Assert.IsTrue(m_textBoxServerName.Properties.Enabled, " m_textBoxServerName should be enabled");

//                m_textBoxServerName.Properties.Text = ".";
//                Assert.IsTrue(m_textBoxDatabaseName.Properties.Enabled, " m_textBoxDatabaseName should be enabled");
//                Assert.IsTrue(m_comboBoxAuthentication.Properties.Enabled, " m_comboBoxAuthentication should be enabled");

//                // set them to null
//                m_textBoxServerName.Properties.Text = "";
//                Assert.IsTrue(m_textBoxDatabaseName.Properties.Enabled == false, " m_textBoxDatabaseName should not be enabled");
//                Assert.IsTrue(m_comboBoxAuthentication.Properties.Enabled == false, " m_comboBoxAuthentication should not be enabled");

//                m_textBoxNickName.Properties.Text = "";
//                Assert.IsTrue(m_textBoxServerName.Properties.Enabled == false, " m_textBoxServerName should not be enabled");

//                m_comboBoxAuthentication.Select(0);
//                Assert.IsTrue(m_textBoxUserName.Properties.Enabled == false, " m_textBoxUserName should not be enabled");
//                Assert.IsTrue(m_textBoxPassword.Properties.Enabled == false, " m_textBoxPassword should not be enabled");

//                m_comboBoxAuthentication.Select(1);
//                Assert.IsTrue(m_textBoxUserName.Properties.Enabled, " m_textBoxUserName should be enabled");
//                Assert.IsTrue(m_textBoxPassword.Properties.Enabled, " m_textBoxPassword should be enabled");

//                m_textBoxNickName.Properties.Text = "testDatabase";
//                m_textBoxServerName.Properties.Text = ".";
//                m_textBoxDatabaseName.Properties.Text = "DBSourceToolsTestDB";
//                Assert.IsTrue(btnOK.Properties.Enabled == true, " btnOK should not be enabled");
//                Assert.IsTrue(btnTestConnection.Properties.Enabled == true, " btnTestConnection should be enabled");

//                //Assert.IsTrue(btnTestConnection.Properties.Enabled == false, " btnTestConnection should be dis-abled");
//            }

//        }

//        [Test]
//        public void TestGetDatabaseObject()
//        {
//            using (DBSourceToolsLib.DatabaseProjectUI.NewDatabaseForm oNewDbForm
//                = new DBSourceToolsLib.DatabaseProjectUI.NewDatabaseForm(false, true))
//            {
//                oNewDbForm.Show();

//                NUnit.Extensions.Forms.TextBoxTester m_textBoxNickName = new NUnit.Extensions.Forms.TextBoxTester("m_textBoxNickName");
//                NUnit.Extensions.Forms.TextBoxTester m_textBoxDatabaseName = new NUnit.Extensions.Forms.TextBoxTester("m_textBoxDatabaseName");
//                NUnit.Extensions.Forms.TextBoxTester m_textBoxServerName = new NUnit.Extensions.Forms.TextBoxTester("m_textBoxServerName");
//                NUnit.Extensions.Forms.ComboBoxTester m_comboBoxAuthentication = new NUnit.Extensions.Forms.ComboBoxTester("m_comboBoxAuthentication");
//                NUnit.Extensions.Forms.ButtonTester btnTestConnection = new NUnit.Extensions.Forms.ButtonTester("btnTestConnection");
//                NUnit.Extensions.Forms.TextBoxTester m_textBoxUserName = new NUnit.Extensions.Forms.TextBoxTester("m_textBoxUserName");
//                NUnit.Extensions.Forms.TextBoxTester m_textBoxPassword = new NUnit.Extensions.Forms.TextBoxTester("m_textBoxPassword");
//                NUnit.Extensions.Forms.ButtonTester btnOK = new NUnit.Extensions.Forms.ButtonTester("btnOk");

//                m_textBoxNickName.Properties.Text = "testDatabaseNick";
//                m_textBoxServerName.Properties.Text = ".";
//                m_textBoxDatabaseName.Properties.Text = "testDB";

//                Assert.IsTrue(btnOK.Properties.Enabled == true, " btnOK should be enabled");
//                btnOK.Click();

//                Database oDatabase = oNewDbForm.GetDatabaseObject();
//                Assert.AreEqual("testDatabaseNick", oDatabase.NickName);
//                Assert.AreEqual(".", oDatabase.DataSourceName);
//                Assert.AreEqual("testDB", oDatabase.DatabaseName);

//            }

//        }

//        [Test]
//        public void TestGetDatabaseObjectWithPassword()
//        {
//            using (DBSourceToolsLib.DatabaseProjectUI.NewDatabaseForm oNewDbForm
//                = new DBSourceToolsLib.DatabaseProjectUI.NewDatabaseForm(false, true))
//            {
//                oNewDbForm.Show();

//                NUnit.Extensions.Forms.TextBoxTester m_textBoxNickName = new NUnit.Extensions.Forms.TextBoxTester("m_textBoxNickName");
//                NUnit.Extensions.Forms.TextBoxTester m_textBoxDatabaseName = new NUnit.Extensions.Forms.TextBoxTester("m_textBoxDatabaseName");
//                NUnit.Extensions.Forms.TextBoxTester m_textBoxServerName = new NUnit.Extensions.Forms.TextBoxTester("m_textBoxServerName");
//                NUnit.Extensions.Forms.ComboBoxTester m_comboBoxAuthentication = new NUnit.Extensions.Forms.ComboBoxTester("m_comboBoxAuthentication");
//                NUnit.Extensions.Forms.ButtonTester btnTestConnection = new NUnit.Extensions.Forms.ButtonTester("btnTestConnection");
//                NUnit.Extensions.Forms.TextBoxTester m_textBoxUserName = new NUnit.Extensions.Forms.TextBoxTester("m_textBoxUserName");
//                NUnit.Extensions.Forms.TextBoxTester m_textBoxPassword = new NUnit.Extensions.Forms.TextBoxTester("m_textBoxPassword");
//                NUnit.Extensions.Forms.ButtonTester btnOK = new NUnit.Extensions.Forms.ButtonTester("btnOk");

//                m_textBoxNickName.Properties.Text = "testDatabaseNick";
//                m_textBoxServerName.Properties.Text = ".";
//                m_textBoxDatabaseName.Properties.Text = "testDB";
//                m_comboBoxAuthentication.Select(1);
//                m_textBoxUserName.Properties.Text = "username";
//                m_textBoxPassword.Properties.Text = "password";

//                Assert.IsTrue(btnOK.Properties.Enabled == true, " btnOK should be enabled");
//                btnOK.Click();

//                Database oDatabase = oNewDbForm.GetDatabaseObject();
//                Assert.AreEqual("testDatabaseNick", oDatabase.NickName);
//                Assert.AreEqual(".", oDatabase.DataSourceName);
//                Assert.AreEqual("testDB", oDatabase.DatabaseName);
//                Assert.AreEqual("username", oDatabase.UserName);
//                Assert.AreEqual("password", oDatabase.Password);

//            }

//        }

//    }
//}
